# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : 组合提示词-聊天提示词组合.py
# @Author: dongguangwen
# @Date  : 2025-03-23 17:41
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage

# 初始化一个 ChatPromptTemplate
prompt = SystemMessage(content="You are a nice pirate")
print(prompt)

# 创建一个管道，将其与其他消息 或 消息模板结合起来
new_prompt = (
    prompt + HumanMessage(content="hi") + AIMessage(content="what?") + "{input}"
)
print(new_prompt)

ret = new_prompt.format_messages(input="i said hi")
print(ret)

"""
content='You are a nice pirate' additional_kwargs={} response_metadata={}
input_variables=['input'] input_types={} partial_variables={} messages=[SystemMessage(content='You are a nice pirate', additional_kwargs={}, response_metadata={}), HumanMessage(content='hi', additional_kwargs={}, response_metadata={}), AIMessage(content='what?', additional_kwargs={}, response_metadata={}), HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['input'], input_types={}, partial_variables={}, template='{input}'), additional_kwargs={})]
[SystemMessage(content='You are a nice pirate', additional_kwargs={}, response_metadata={}), HumanMessage(content='hi', additional_kwargs={}, response_metadata={}), AIMessage(content='what?', additional_kwargs={}, response_metadata={}), HumanMessage(content='i said hi', additional_kwargs={}, response_metadata={})]
"""
